<template>
  <Nav_bar v-show="showNav && !isLoading"></Nav_bar>
  <router-view v-show="!isLoading" :key="refreshUuid"></router-view>
  <LoadingCover v-show="isLoading"/>
</template>

<script setup>
import appStore from "@/store";
import { storeToRefs } from "pinia";
import LoadingCover from "@/components/common/loadingCover.vue";
import Nav_bar from "@/components/common/Navbar.vue";

const { isLoading } = storeToRefs(appStore.useLoadingStore);
const { refreshUuid } = appStore.useRefreshStore;
const { showNav } = storeToRefs(appStore.useNavbarStore);

const { getAndUpdateUserInfo, keepLogout } = appStore.useUserInfoStore;
// User authentication
const token = localStorage.getItem('token');
if (token) {
  getAndUpdateUserInfo();
} else {
  keepLogout();
}
</script>

<style scoped>

</style>